package com.rjwh.dingdong.client.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.rjwh.dingdong.client.R;
import com.rjwh.dingdong.client.bean.localbean.LocalGmaeInfo;
import com.rjwh.dingdong.client.util.ViewHolder;

/**
 * @author Kay
 * @ClassName DrawBookMyCatalogGvAdapter
 * @Description
 * @date 2016-8-8
 * @history 2016-8-8 author: description:
 */
public class DrawBookMyCatalogGvAdapter extends AdapterBase<LocalGmaeInfo> {
    private Context context;

    public DrawBookMyCatalogGvAdapter(Context context) {
        this.context = context;
    }

    @Override
    protected View getExView(int position, View convertView, ViewGroup parent) throws Exception {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.draw_book_my_catalog_item, null);
        }
        ImageView bookImg = ViewHolder.get(convertView, R.id.draw_book_my_catalog_item_img);
        TextView bookTitle = ViewHolder.get(convertView, R.id.draw_book_my_catalog_item_title_tv);

        LocalGmaeInfo info = getList().get(position);
        String pic = info.getPic();
        String pname = info.getPname();
        if (pic != null) {
            Glide.with(context).load(pic).dontAnimate().placeholder(R.drawable.icon_drawbook_pic_holder).error(R.drawable.icon_drawbook_pic_holder).diskCacheStrategy(DiskCacheStrategy.ALL).into(bookImg);
        }
        if (pname != null) {
            bookTitle.setText(pname);
        }
        return convertView;
    }
}
